package com.example.demo.controller.voj;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.common.IdParam;
import com.example.demo.domain.entity.VojObjectiveQuestion;
import com.example.demo.dto.ResponseDto;
import com.example.demo.dto.VojObjectiveQuestionsListDto;
import com.example.demo.param.voj.VojObjectiveQuestionsListParam;
import com.example.demo.param.voj.VojObjectiveQuestionsSaveParam;
import com.example.demo.service.VojObjectiveQuestionsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * 题库模块-客观题
 */
@Controller
@RequestMapping("/objectiveQuestions")
public class ObjectiveQuestionController {

    private static final Logger LOGGER = LoggerFactory.getLogger(ObjectiveQuestionController.class);

    @Resource(name = "vojObjectiveQuestionsServiceImpl")
    private VojObjectiveQuestionsService objectiveQuestionsService;


    /**
     * 新建、编辑、禁用客观题
     * @param param
     * @return
     */
    @RequestMapping("/save")
    @ResponseBody
    public ResponseDto save(@RequestBody VojObjectiveQuestionsSaveParam param) {
        ResponseDto responseDto = new ResponseDto<>().buildSucceed();
        objectiveQuestionsService.save(param);
        return responseDto;
    }

    /**
     * 删除客观题
     * @param param
     * @return
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseDto delete(@RequestBody IdParam param) {
        ResponseDto responseDto = new ResponseDto<>().buildSucceed();
        objectiveQuestionsService.delete(param);
        return responseDto;
    }

    /**
     * 查询客观题
     * @param param
     * @return
     */
    @RequestMapping("/list")
    @ResponseBody
    public ResponseDto<Page<VojObjectiveQuestionsListDto>> list(@RequestBody VojObjectiveQuestionsListParam param) {
        Page list = objectiveQuestionsService.list(param);
        ResponseDto responseDto = new ResponseDto<>().buildSucceedHasData(list);
        return responseDto;
    }
    /**
     * 设置为公共题库[仅限管理员]
     * @param param
     * @return
     */
    @RequestMapping("/setPublic")
    @ResponseBody
    public ResponseDto setPublic(@RequestBody IdParam param) {
        objectiveQuestionsService.setPublic(param);
        ResponseDto responseDto = new ResponseDto<>().buildSucceed();
        return responseDto;
    }


}
